
//localStorage["Magnus Prime Receiver"]=1
//if(localStorage[i]==undefined)

function RemoveSave(){
    var check=confirm("是否清除记录并显示所有出库部件")
    if(check){
        localStorage.clear()
        location.reload()
    }
}

function RelicByPrice(){
    localStorage.part=0
    //document.getElementById("001").innerHTML="ERROR"
    //return 0
    var table = ""
    //document.getElementById("001")
    //写入表头
    table="<tr><th>核桃</th><th>系数</th><th>纪元</th></tr>";
    //写入数据
    var Relic_name=""
    var price_xishu=0
    for(Relic_name in RelicPrice){
        console.log(Relic_name)
        price_xishu=RelicPrice[Relic_name]["系数"]

        table+="<tr><td>"+Relic_name+"</td><td>"+price_xishu+"</td><td>"+RelicPrice[Relic_name]["类别"]+"</td></tr>"
    }
    document.getElementById("001").innerHTML=table
}

function PartByIntroduced(){
    localStorage.part=1
    var i=0
    //document.getElementById("001")
    var table='<tr><th>部件</th><th colspan="99">核桃</th></tr>'
    //排序
    var arr=[]
    for (part_name in IntroducedPart){
        arr.push(part_name);
    }
    arr.sort()
    console.log(arr)

    for (i in arr){
        part_name=arr[i]
        console.log(part_name)
        if(localStorage[part_name]=="1"){continue}
    //for (part_name in IntroducedPart){
        if(part_name == undefined){
            continue
        }
        console.log(part_name)
        table+='<tr><td title="'+part_name+'" onclick=LogGetPat(this)>'+PartName_zh[part_name]+"</td>"
        for (i=0;i<=15;i++){
            try{
                if(IntroducedPart[part_name][i]["Rarity"]=="金"){
                    table+='<td bgcolor="Yellow">'+IntroducedPart[part_name][i]["Relic"]+"</td>"
                    console.log(IntroducedPart[part_name][i]["Relic"])
                    }
                else if(IntroducedPart[part_name][i]["Rarity"]=="银"){
                    table+='<td bgcolor="AliceBlue">'+IntroducedPart[part_name][i]["Relic"]+"</td>"
                    console.log(IntroducedPart[part_name][i]["Relic"])
                }
                else if(IntroducedPart[part_name][i]["Rarity"]=="铜"){
                    table+='<td bgcolor="AntiqueWhite">'+IntroducedPart[part_name][i]["Relic"]+"</td>"
                    console.log(IntroducedPart[part_name][i]["Relic"])
                }
                else break
            }catch (error) {
                break
            }
        }
        table+="</tr>"
        document.getElementById("001").innerHTML=table
    }



}

//{"Drops":[{"Item":"","Part":"","Rarity":""}]"Vaulted":False}
function RelicByIntroduced(){
    localStorage.part=2
    var table='<tr><th>核桃</th><th colspan="3">部件</th></tr>'
    for(Relic in RelicData){
        console.log(Relic)
        if(RelicData[Relic]["Vaulted"]){
            continue
        }else{
            Relic_tr='<tr><td>'+Relic+'</td>'
            //table+='<tr><td>'+Relic+'</td>'
            //table+='<tr><td rowspan="3">'+Relic+'</td>'
            var cont=0
            var color=""
            for(var i=0;i<6;i++){
                if(RelicData[Relic]["Drops"][i]["Item"]=="Forma"){continue}
                part_name=RelicData[Relic]["Drops"][i]["Item"]+" "+RelicData[Relic]["Drops"][i]["Part"]
                if(localStorage[part_name]=="1"){continue}
                switch(RelicData[Relic]["Drops"][i]["Rarity"]){
                    case "Common":
                        color="AntiqueWhite"
                        break
                    case 'Uncommon':
                        color="AliceBlue"
                        break
                    case "Rare":
                        color="Yellow"
                        break
                    default:
                        color="White"
                }
                switch(cont){
                    case 0:
                        Relic_tr+='<td bgcolor="'+color+'" onclick=LogGetPat(this)  title="'+part_name+'">'+PartName_zh[part_name]+'</td>'
                        break
                    case 1:
                    case 3:
                    case 5:
                        Relic_tr+='<td bgcolor="'+color+'" onclick=LogGetPat(this)  title="'+part_name+'">'+PartName_zh[part_name]+'</td></tr>'
                        break
                    case 2:
                    case 4:
                        Relic_tr+='<tr><td></td><td bgcolor="'+color+'" onclick=LogGetPat(this)  title="'+part_name+'">'+PartName_zh[part_name]+'</td>'
                }
                cont++
            }
            if(cont==0){continue}
            table+=Relic_tr
            if(cont%2==0){Relic_tr+='</tr>'}
        }
    }
    document.getElementById("001").innerHTML=table
}
function LogGetPat(key){
    if(key.title==undefined){return 0}
    var check=confirm("是否隐藏部件："+PartName_zh[key.title])
    if(check){
        localStorage[key.title]=1
        location.reload()
    }

}



switch(localStorage.part){
    case "0":
        RelicByPrice()
        break
    case "1":
        PartByIntroduced()
        break
    case "2":
        RelicByIntroduced()
        break
    default:
        PartByIntroduced()
}

